﻿using System;
using System.Device.Location;
using Windows.Devices.Geolocation;

namespace Chenglin.WPMyStep
{
    public static class Extensions
    {
        public static bool IsTrue(this bool? b)
        {
            return b.HasValue && b.Value;
        }

        public static GeoCoordinate ToGeoCoordinate(this Geocoordinate geocoordinate)
        {
            return new GeoCoordinate
                (
                    geocoordinate.Latitude,
                    geocoordinate.Longitude,
                    geocoordinate.Altitude ?? Double.NaN,
                    geocoordinate.Accuracy,
                    geocoordinate.AltitudeAccuracy ?? Double.NaN,
                    geocoordinate.Speed ?? Double.NaN,
                    geocoordinate.Heading ?? Double.NaN
                );
        }
    }
}
